package com.hmjk.health.background.data;


import java.util.HashMap;

import com.hmjk.health.HealthApp;
import com.hmjk.health.background.DataManager;

public abstract class DataUpdated{
	public long UPDATE_TIME;
	protected int MIN_QUERY_DUR = 10;
	
	long reqTime = 0;
	long upTime = 0;
	DataManager mDm;
	HealthApp mApp;
	DataUpdated mBaseData;
	//DataUpdated mNotifer;
	HashMap<String, DataUpdated> mNotifersMap = new HashMap<String, DataUpdated>();
	
	public long checkRequestTime(){
		return reqTime;
	}
	public abstract void setUserData(Object data);
	public abstract long delay();
	public abstract boolean grab();
	public abstract boolean grabByUser();
	public boolean grabByUserWithSingleArgs(Object args){
		return false;
	}
	public abstract void receive(String stamp, String sjson);
	public abstract Object check(String[] arg);
	public abstract boolean commit(Object data);
	public abstract void release();
	public DataUpdated(HealthApp app, DataManager dm) {
		this(app, dm, null);
	}
	
	public DataUpdated(HealthApp app, DataManager dm, DataUpdated baseData) {
		mDm = dm;
		mApp = app;
		UPDATE_TIME = 2 * 60 * 1000; //default 2 minute
		mBaseData = baseData;
	}
	
	public void setNotifer(String key,DataUpdated n){
		//mNotifer = n;
		mNotifersMap.put(key, n);
	}
	
	public DataUpdated getNotifier(String key)
	{
		return mNotifersMap.get(key);
	}
}
